from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker

from conf.variable import MYSQL_CONFIG


class MysqlCnxPool:
    def __init__(self):
        engine = create_engine(MYSQL_CONFIG['url'])
        self.engine = engine
        self.DBSession = sessionmaker(bind=engine)

    def get_session(self):
        DBSession = self.DBSession
        return DBSession()

    def get_conn(self):
        return self.engine.connect()
